React = require('react')
Card = require('antd-mobile/lib/card')
# ListView = require('antd-mobile/lib/list-view')
Flex = require('antd-mobile/lib/flex')
Icon = require('antd-mobile/lib/icon')
Toast = require('antd-mobile/lib/toast')
RefreshControl = require('antd-mobile/lib/refresh-control')
{View,Image,Text,ScrollView,TouchableHighlight,StyleSheet,Navigator,ListView,TouchableOpacity} = require('react-native')
Dimensions = require('Dimensions')
{ width, height } = Dimensions.get('window')
{View} = require('react-native')
{fetchGetList,fetchRefreshList} = require('../actions/page_hxjg.js')
{connect} = require('react-redux')
_ = require('underscore')

backImg = require('../img/back.png')
searchIcon = require('../img/search_white.png')
renderAfterTransfer = require('../highOrderComponent/renderAfterTransfer.js')
basePage = require('../mixins/basePageNew.js')
DescPage = require('./page_hxjg_detail.js')
Page_hxjg = React.createClass
  mixins:[basePage]
  componentDidMount:->
    @initFetchData()
  rowClick:(model)->
    {navigator} = @props
    setTimeout ->
      navigator.push
        component:DescPage
        name:'inAttempDesc'
        title:'详情'
        params:
          model:model
    ,200
  renderRow:(rowData,sectionID,rowID,highlightRow)->
    <TouchableHighlight onPress={@rowClick.bind(@,rowData)} key={rowData.id}>
      <View style={styles.row}>
        <Text style={[styles.text,{fontWeight:'bold'}]}>
          {rowData.notice_name}
        </Text>
        <View style={{flexDirection:'row'}}>
          <Text style={styles.text}>
            {rowData.publish_date}
          </Text>
        </View>
      </View>
    </TouchableHighlight>
  renderHeader:->
      <View style={{flexDirection:'row',flex:0,height:60,alignItems:'center', justifyContent:'center',backgroundColor:'#0066FF'}}>
        <View style={{flex:1,padding:10}}>
          <TouchableOpacity onPress={=>@props.navigator.pop()}>
            <Image source={backImg}  style={{height:30,width:30,resizeMode:'contain'}}/>
          </TouchableOpacity>
        </View>
        <View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
          <Text style={{fontSize:20,color:'#ffffff'}}>航行警告</Text>
        </View>
        <View style={{flex:1,alignItems:'flex-end',padding:10}}>
          <TouchableOpacity onPress={@_showActionSheet}>
          </TouchableOpacity>
        </View>
      </View>

styles = StyleSheet.create
  row:
    flexDirection:'column'
    justifyContent:'center'
    padding:10
    backgroundColor:'#F6F6F6'
  text:
    flex:1

mapStateToProps = (state)->
  debugger
  list:state.page_hxjg.list
  isLoading:state.page_hxjg.isLoading
  completed:state.page_hxjg.completed
  refreshing:state.page_hxjg.refreshing
  connected:state.appState.connected
mapDispatchToProps = (dispatch,wonProps)->
  fetchGet:()->
    dispatch fetchGetList()
  fetchRefresh:->
    dispatch fetchRefreshList()
module.exports = connect(mapStateToProps,mapDispatchToProps)(Page_hxjg)
